package com.funkids.prxis.controller;


import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.funkids.common.Result;
import com.funkids.common.dto.GoodsDto;
import com.funkids.prxis.entity.SysGoods;
import com.funkids.prxis.entity.SysUser;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author funkids
 * @since 2023-03-22
 */
@RestController
@RequestMapping("/prxis/sysGoods")
public class SysGoodsController extends BaseContoller{

    @GetMapping("/list")
    public Result getGoodsList(String name){
//        Page<SysUser> pageData = sysGoodsService.page(getPage(), new QueryWrapper<SysGoods>()
//                .like(StrUtil.isNotBlank(name), "goods_name", name));
//        System.out.println(pageData.getRecords());

//        return Result.succ(pageData);

        //实现显示GoodsDto的列表页
        Page<GoodsDto> page = getPage();
        Page<GoodsDto> pageData =  sysGoodsService.getGoodsPage(page,name);
        System.out.println(pageData.getCurrent()+":"+pageData.getSize());
        return Result.succ(pageData);
    }
}

